package server

import (
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

type Server struct {
	router *gin.Engine
	port   string
}

func NewServer(port string) *Server {
	router := gin.Default()
	return &Server{
		router: router,
		port:   port,
	}
}

func( s *Server) RegisterRoutes(register func(*gin.Engine)){
	register(s.router)
}

func (s *Server) Start() error{
	log.Printf("服务启动：%s",s.port)
	return http.ListenAndServe(s.port,s.router)
}